home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / Draw / Sources / DrwPrmse.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  3.9 KB  |  180 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrwPrmse.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #include "ODFDraw.hpp"
  13.  
  14. #ifndef DRWPRMSE_H
  15. #include "DrwPrmse.h"
  16. #endif
  17.  
  18. #ifndef DRAWCONT_H
  19. #include "DrawCont.h"
  20. #endif
  21.  
  22. #ifndef BINDING_K
  23. #include "Binding.k"
  24. #endif
  25.  
  26. #ifndef DRAWPRXY_H
  27. #include "DrawPrxy.h"
  28. #endif
  29.  
  30. #ifndef DRAWPART_H
  31. #include "DrawPart.h"
  32. #endif
  33.  
  34. #ifndef DRAWSEL_H
  35. #include "DrawSel.h"
  36. #endif
  37.  
  38. #ifndef BASESHP_H
  39. #include "BaseShp.h"
  40. #endif
  41.  
  42. #ifndef BOUNDSHP_H
  43. #include "BoundShp.h"
  44. #endif
  45.  
  46. #ifndef LINESHP_H
  47. #include "LineShp.h"
  48. #endif
  49.  
  50. #ifndef OVALSHP_H
  51. #include "OvalShp.h"
  52. #endif
  53.  
  54. #ifndef RECTSHP_H
  55. #include "RectShp.h"
  56. #endif
  57.  
  58. #ifndef RRECTSHP_H
  59. #include "RRectShp.h"
  60. #endif
  61.  
  62. #ifndef TEXTSHP_H
  63. #include "TextShp.h"
  64. #endif
  65.  
  66. #ifndef UTILS_H
  67. #include "Utils.h"
  68. #endif
  69.  
  70. // ----- OS Layer -----
  71.  
  72. #ifndef FWSUSINK_H
  73. #include "FWSUSink.h"
  74. #endif
  75.  
  76. #ifndef FWORDCOL_H
  77. #include "FWOrdCol.h"
  78. #endif
  79.  
  80. #ifndef FWPICTUR_H
  81. #include "FWPictur.h"
  82. #endif
  83.  
  84. // ----- Foundation Includes -----
  85.  
  86. #ifndef FWSTREAM_H
  87. #include "FWStream.h"
  88. #endif
  89.  
  90. #ifndef FWPRISTR_H
  91. #include "FWPriStr.h"
  92. #endif
  93.  
  94. #ifndef FWMEMMGR_H
  95. #include "FWMemMgr.h"
  96. #endif
  97.  
  98. #ifndef FWMEMHLP_H
  99. #include "FWMemHlp.h"
  100. #endif
  101.  
  102. #ifndef FWSOMENV_H
  103. #include "FWSOMEnv.h"
  104. #endif
  105.  
  106.  
  107. // ----- OpenDoc Includes -----
  108.  
  109. #ifndef SOM_Module_OpenDoc_StdProps_defined
  110. #include <StdProps.xh>
  111. #endif
  112.  
  113. #ifndef SOM_ODStorageUnitView_xh
  114. #include <SUView.xh>
  115. #endif
  116.  
  117. //========================================================================================
  118. // RunTime Info
  119. //========================================================================================
  120.  
  121. #ifdef FW_BUILD_MAC
  122. #pragma segment odfdraw
  123. #endif
  124.  
  125. //========================================================================================
  126. //    class CDrawPromise
  127. //========================================================================================
  128.  
  129. //----------------------------------------------------------------------------------------
  130. //    CDrawPromise::CDrawPromise
  131. //----------------------------------------------------------------------------------------
  132.  
  133. CDrawPromise::CDrawPromise(Environment*ev, 
  134.                                             FW_StorageKinds storageKind, 
  135.                                             FW_CCloneInfo* cloneInfo, 
  136.                                             CDrawPromiseContent* promisedContent,
  137.                                             FW_CLinkSource* linkSrc) :
  138.     FW_CPromise(ev, storageKind, cloneInfo, linkSrc),
  139.     fPromisedContent(promisedContent)
  140. {
  141.     fPromisedContent->PromiseShape(ev, storageKind, TRUE);
  142. }
  143.  
  144. //----------------------------------------------------------------------------------------
  145. //    CDrawPromise::~CDrawPromise
  146. //----------------------------------------------------------------------------------------
  147.  
  148. CDrawPromise::~CDrawPromise()
  149. {
  150.     FW_SOMEnvironment ev;
  151.         
  152.     fPromisedContent->PromiseShape(ev, GetStorageKind(ev), FALSE);
  153.  
  154.     // Draw links just provide a reference to their own content, so don't delete that!
  155.     if (this->GetStorageKind(ev) != FW_kLinkStorage)
  156.         delete fPromisedContent;
  157. }
  158.  
  159. //----------------------------------------------------------------------------------------
  160. //    CDrawPromise::FulfillPromise
  161. //----------------------------------------------------------------------------------------
  162.  
  163. void CDrawPromise::FulfillPromise(Environment *ev, 
  164.                                             FW_CPart* part,
  165.                                             ODStorageUnitView *promiseSUView, 
  166.                                             ODPropertyName propertyName, 
  167.                                             ODValueType valueType, 
  168.                                             FW_CCloneInfo* cloneInfo)
  169. {
  170. #ifndef FW_DEBUG
  171. FW_UNUSED(propertyName);
  172. #endif
  173.     FW_ASSERT(FW_PrimitiveStringEqual(propertyName, kODPropContents)); // We only promised the kODPropContents
  174.     
  175.     FW_CKind* kind = part->GetKind(ev, valueType);
  176.     FW_ASSERT(kind);
  177.     
  178.     fPromisedContent->ExternalizeKind(ev, promiseSUView->GetStorageUnit(ev), kind, GetStorageKind(ev), NULL, cloneInfo);
  179. }
  180.